package com.freewater.springboot.demo.ioc.qualifier.genericqualifier;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(AppConfig.class);
        applicationContext.refresh();
        applicationContext.registerShutdownHook(); // 注册jvm关闭回调，jvm关闭时一并关闭spring容器
        final Shop shop = applicationContext.getBean(Shop.class);
        System.out.println(shop.getStringStore().getBeanName());
        System.out.println(shop.getIntegerStore().getBeanName());
        System.out.println(shop.getStringStores().stream().map(Store::getBeanName).collect(Collectors.joining(",")));
        System.out.println(shop.getIntegerStores().stream().map(Store::getBeanName).collect(Collectors.joining(",")));
    }
}
